package com.cjg.xiancheng;

public class threadStop implements Runnable   {

    //如果不填 boolean的默认值为flase
    private  boolean flag=true;
    @Override
    public void run() {
        int i =1;
       while (flag){
           System.out.println("fuck"+i++);
       }

    }
    public void stop(){
        this.flag=false;
    }

    public static void main(String[] args) {
        threadStop threadStop = new threadStop();
        new Thread(threadStop,"me").start();

        for (int i = 0; i < 1000; i++) {
            System.out.println("main"+i);
            if (i==500){
                threadStop.stop();
                System.out.println("stop=============================================================================");
            }
        }


    }
}
